package com.chengliang.zuoye.controller;

import com.chengliang.zuoye.bean.WorkTask;
import com.chengliang.zuoye.response.JsonResult;
import com.chengliang.zuoye.service.WorkTaskService;
import com.github.pagehelper.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author chengliang
 * @Date 2019-06-25 22:53
 * @Description //TODO
 *  作业任务控制器
 */
@Controller
@RequestMapping("/work/task")
public class WorkTaskController {

    private Logger logger= LoggerFactory.getLogger(getClass());

    @Autowired
    private WorkTaskService workService;

    /**
     * 作业任务首页
     * @return
     */
    @GetMapping("/index")
    public String index(){
        return "work/task/index";
    }

    /**
     * 主页列表数据
     * @return
     */
    @GetMapping("/data/json")
    @ResponseBody
    public Object data(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit){
        Page<WorkTask> workTaskPage = workService.getWorkList(page, limit);
        return JsonResult.ok(workTaskPage.getResult()).append("count", workTaskPage.getTotal());
    }
}
